package com.chenjj.java.test.oom;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * 内存溢出测试
 *
 * -Xms5m -Xmx10m -XX:NewSize=6m -Xloggc:D:/tmp/gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:/tmp -XX:ErrorFile=D:/tmp/error.log -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC
 */
public class OomTester {

    @Test
    public void test() throws InterruptedException {
        List list =new ArrayList();
        int i = 0;
        while (true){
            //Thread.sleep(10);
            list.add(new Person(i+""));
        }
    }


    class Person{
        String name;

        public Person(String name){
            this.name = name;
        }
    }
}
